/*
ForwardHRController
Version 1.0
Description: Controller class for ForwardHR page.
Author: Pratibh Prakash
Created Date: 10 Feb-2009
*/
public class ForwardHRController {

    private HR__c objHR;//Object for storing HR__c record.
    private User user;//Object for storing User record.
    private String idUser, idHR;//Variables store UserId and HR__c Id which are retreived from current PageReference.
    PageReference currentPage;//Object for storing current page reference.
    Map<String, String> parameters = new Map<String, String>();// Map for storing paramters and respective values from current PageReference. 
    
    /*
    ForwardHRController(): Constructor
    Initializes all the properties of the class using paramters in the URL.
    */
    public ForwardHRController() {
        
        currentPage = ApexPages.currentPage();//Getting current page Reference.
        parameters = currentPage.getParameters();//Retreiving parameters from current PageReference.
        idUser = parameters.get('newid');//Retreiving UserId from Map.
        idHR = parameters.get('hr');//Retreiving HR__c.Id from Map.
        user = [select id, Alias from User where id=:idUser];
        objHR = [select Id,Last_Name__c,User__c from HR__c where id=: idHR];
        
    }
    /*
    GotoHR()
    Description: Method used to redirect from new User page to HR__c list page.
    */
    public PageReference GotoHR(){
    
        objHR.User__c = user.id;//Relating respective User and HR record.
        PageReference userPage = new PageReference('/'+objHR.Id);//Creating PageReference for HR__C detail view page.
        userPage.setRedirect(true);
        update(objHR);
        return userPage;
       
    }
        
    
}